<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['pluginset']=$this->plugin_setting('basic');
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'end_time >'=>time());
	if($_RQ['keyword']){
		$keys['title like']='%'.trim($_RQ['keyword']).'%';
		$goodsids = pdo_getall('jy_weishop_goods',$keys,array('id'),'id');		
		$goodsids=array_keys($goodsids);		
		$params['goods_id']=$goodsids;
	}
	if($_RQ['keyword'] && !$goodsids ){
		$return['list']='';
	}else{
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_bargain_goods',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
			$good=pdo_get('jy_weishop_goods',array('id'=>$v['goods_id']),array('image','price','title'));
			$v['image']=tomedia($good['image']);
			$v['price']=$good['price'];
			$v['title']=$good['title'];
	}
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['sharedata']=array(
			'title'=>$basic['share_title']?$basic['share_title']:'首页-在线砍价',
			'desc'=>$basic['share_desc']?$basic['share_desc']:'在线砍价商城！',
			'link'=>custom_url('jy_bargain/index//fromuser='.$_SESSION['uid'],true),
			'imgUrl'=>tomedia($basic['share_image'])
	);
	set_html('title',$basic['title']?:'砍价首页');
	exi($return);
}